// function request(url, method, data, showLoading = true) {
    // if (showLoading) {
    //     wx.showLoading({
    //         title: '加载中...',
    //     })
    // }
function request(url, method, data, showLoading = true) {

    return new Promise((resolve, reject) => {
        wx.request({
            url: ' http://123.207.219.13:3003'+url,
            method: method,
            data: data,
            success(res) {
                if (showLoading) {
                    wx.hideLoading()
                }
                resolve(res.data)
            },
            fail(err) {
                if (showLoading) {
                    wx.hideLoading()
                }
                reject(err)
            },
            // complete() {
            //     if (showLoading) {
            //         wx.hideLoading()
            //     }
            // }
        })
    })
}

module.exports = {
    request: request
}